<?php

function url_get($what){
    $urls = array(
        "index" => "?action=index",
        "login" => "?action=login",
        "list"  => "?action=list",
        "post"  => "?action=post",
        "generate" => "?action=generate",

        "page"  => "/page/",
        "res"   => "/res/",
    );

    if(!empty($urls[$what])){
        return "http://www." . url_get_domain() . "/" . $urls[$what];
    } else {
        return false;
    }
}

function url_redirect($url){
    header("Location: " . $url);
    exit;
}

function url_append_param($url, $param){
    if(strpos($url, "?") === false){
        $url .= "?";
    } elseif (strstr($url, "?") != "?"){
        $url .= "&";
    }
    $url .= http_build_query($param);
    return $url;
}

function url_get_domain(){
    return 'xxx.xxx';
}

function url_get_current_path(){
    $path = $_SERVER['REQUEST_URI'];
    return dirname($path);
}

function url_404(){

    @ob_clean();
    header("HTTP/1.0 404 Not Found");
    echo <<<EAE
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>404 Not Found</title>
</head><body>
<h1>Not Found</h1>
<p>The requested URL was not found on this server.</p>
<hr>
<address>Apache Server</address>
</body></html>
EAE;
    exit;
}

